//声明: 该文件需要 swiper,jqueryui,common,toast,jquery

require(["config"], function(config) {
	require(["jquery.ui", "jquery", "sw", "toast", "my.hover"], function(jqui, jq, sw, t, mh) {

			
			
			
			
		var mySwiper = new Swiper('.swiper-container1', {
			autoplay: 3000,
			effect: 'fade',

			// 如果需要分页器
			pagination: '.swiper-p1',

			// 如果需要前进后退按钮
			nextButton: '.n_left',
			prevButton: '.n_right',
		})
			
			
			
		//	限时秒杀

		function ms(data) {
			for(var i in data.tp) {
				$(".xsms").append("<a href='nvzhuang.html'><img src=" + data.tp[i] + ">");

			}
			
		}

		$.get("json1/miaosha.json", function(data) {
			ms(data);
		})

		//秒杀2
		function ms2(data) {
			$(".ms2").last().append("<div class='biaoti'>").last().append("<div class='daojishi'>").append("<div class='xsms2'>")
			$(".biaoti").append("<span>" + data.bt + "<i>" + data.yw + "");
		
			$(".xsms2").last().append("<div class='dtp'><a href='#'><img src=" + data.dt + ">");

			var num = 0;
			for(var i in data.zong) {

				$(".xsms2").last().append("<li class='lik'><a href='chanpin.html' class='tu'><img src=" + data.zong[i].pic + ">");

				$(".xsms2 .lik").eq(num).append("<a class='cp'>" + data.zong[i].name + "").append("<span>" + data.zong[i].xj + "<i>" + data.zong[i].yj + "");

				num++;
			}

			

		}

		$.get("json1/msx.json", function(data) {
			ms2(data);
		})

		function jx(data) {
			$(".biaoti3").append("<div class='zgjp'><span>"+data.bt + "<i>" + data.yw + "")
			for(var i in data.pic) {
				$(".jxcp").last().append("<div class='div1'><a><img src=" + data.pic[i] + ">")

			}
			$(".div1").append("<a href='chanpin.html'><img class='zheceng' src=" + data.zheceng + ">")
			$(".div1").css({ "position": "relative", "height": 350, "overflow": "hidden" })
			$(".zheceng").css({ "position": "absolute", "left": -232 });
			//利用扩展方法
			$(".div1").hoverdir();
			//效果
			/*$(".div1").bind("mouseenter mouseleave",function(e) {
           var w = $(this).width();
           var h = $(this).height();
           var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
           var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
           //alert(x);
		   var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
           //direction的值为“0,1,2,3”分别对应着“上，右，下，左”
           var eventType = e.type;
           //alert(e.type);
           if(e.type == 'mouseenter'){
              if(direction==0){
              	$(this).find('.zheceng').css({'display':'block','top':-h+'px','left':'0px'}).stop().animate({'top':'0px'});
              }else if(direction==1){
              	$(this).find('.zheceng').css({'display':'block','left':w+'px','top':'0px'}).stop().animate({'left':'0px'});
              }else if(direction==2){
              	$(this).find('.zheceng').css({'display':'block','top':h+'px','left':'0px'}).stop().animate({'top':'0px'});
              }else if(direction==3){
              	$(this).find('.zheceng').css({'display':'block','left':-w+'px','top':'0px'}).stop().animate({'left':'0px'});
              }
          }else{
              if(direction==0){
              	$(this).find('.zheceng').stop().animate({'top':-h+'px'});
              }else if(direction==1){
              	$(this).find('.zheceng').stop().animate({'left':w+'px'});
              }else if(direction==2){
              	$(this).find('.zheceng').stop().animate({'top':h+'px'});
              }else if(direction==3){
              	$(this).find('.zheceng').stop().animate({'left':-w+'px'});
              }
          }
      });*/
		}

		$.get("json1/jingxuan.json", function(data) {
			jx(data);
		})

		function gj(data) {
			$(".biaoti5").append("<div class='zgjp'><span>"+data.bt + "<i>" + data.yw + "")
			$("#gjsp").append("<div class='spzs'><a><img src=" + data.pic1 + ">").append("<div class='spys'>").append("<div class='spyx'>").append("<div class='spzx'>").append("<div class='fud'>");
			for(var i in data.pic2) {
				$(".spys").append("<a href='#'><img src=" + data.pic2[i] + ">");
			}

			for(var j in data.pic3) {
				$(".spyx").append("<a href='#'><img src=" + data.pic3[j] + ">");
			}
			for(var k in data.pic4) {
				$(".spzx").append("<li><a>" + data.pic4[k] + "");
			}

			$(".fud").append("<a>" + data.pic5 + "");
			
			$("#gjsp").last().append("<div class='swiper-container swiper-container2'>");
			$(".swiper-container2").append("<div class='swiper-wrapper'>").append("<div class='swiper-button-prev n_left1'>").append("<div class='swiper-button-next n_right1'>").css({"margin-top":6,"background":"#fff"});
			for(var i in data.pic6) {
				$(".swiper-wrapper").append("<div class='swiper-slide lwc-imghandle1' ><img class='img1' src=" + data.pic6[i] + ">")
			}
			
			
		var mySwiper = new Swiper('.swiper-container2', {
			loop:true,
			slidesPerView:2,
			prevButton:'.n_left1',
			nextButton:'.n_right1',
			width:280,
			height:50
			})

		}

		$.get("json1/gjsp.json", function(data) {

			gj(data);
		})

		function zongtu(data) {
		$(".zt").append("<div class='biaoti6'><span>"+data.bt + "<i>" + data.yw + "").last().append("<div class='zhongjian'>");
		
		$(".zhongjian").append("<div class='z_left'>").last().append("<div class='z_right'>");
		$(".z_left").append("<div class='left_top'><img src="+data.zhu1+">").append("<div class='left_bot'>");
		$(".left_bot").append("<div class='left_bot_top'>").append("<div class='left_bot_bot'>");
		for(var i in data.pic3){
			$(".left_bot_top").append("<li><a href='#'>"+data.pic3[i]+"");
		};
		for(var a in data.pic4){
			$(".left_bot_bot").append("<a href='#'><img src="+data.pic4[a]+">");
		};
		$(".z_right").append("<div class='right_top'>")	.append("<div class='right_bot'>");
		for(var b in data.pic1){
			$(".right_top").append("<a href='#'><img src="+data.pic1[b]+">");
			
		}
		for(var c in data.pic2){
			$(".right_bot").append("<a href='#'><img src="+data.pic2[c]+">")
		}
	}	
	

		$.get("json1/zhutu.json", function(data) {

			zongtu(data);
		})

	});

})